
let data = localStorage.getItem('now')
if (data) {
    data = JSON.parse(data)
    Array.from(data).forEach((v) => {
        let id = v.goods_id
        let src = v.img_big_logo
        let price = v.price
        let tips = v.title
        // let num = valueObj
        document.querySelector('.img img').src = v.img_big_logo
        document.querySelector('.top1').innerHTML = v.title
        document.querySelector('.money-value').innerHTML = v.price
        
    })

}
let reduceObj = document.querySelector('.count .reduce')
let addObj = document.querySelector('.count .add')
let valueObj = 1
//!"previousElementSibling" 是 JavaScript 中的一个属性,表示某个元素的前一个兄弟元素。
addObj.previousElementSibling.onblur = function () {
    valueObj = addObj.previousElementSibling.value - 0

}
addObj.onclick = function () {
    valueObj = valueObj + 1
    addObj.previousElementSibling.value = valueObj
}
reduceObj.onclick = function () {
    if (valueObj == 1) {
        reduceObj.style.userSelect = 'none'
    } else {
        valueObj = valueObj - 1
        addObj.previousElementSibling.value = valueObj

    }
}


let btnOne = document.querySelector('.btn-brank-one')
let btnTow = document.querySelector('.btn-brank-tow')

btnOne.onclick = function(){
    let num = document.querySelector("#goods-count").value;
    // console.log(num);
    localStorage.setItem("buyNum",num)
    location.href="http://127.0.0.1:5502/cart.html"


}






